from django.db import models
from article.models import Article
from django.contrib.auth.models import  User
from ckeditor.fields import RichTextField

# 评论
class Comment(models.Model):
    article = models.ForeignKey(Article,on_delete=models.CASCADE)   # 对应的文章
    content = RichTextField()   # models.TextField()    # 评论内容
    user = models.ForeignKey(User,on_delete=models.CASCADE) # 评论人
    created  = models.DateTimeField(auto_now_add=True)  # 评论时间



    class Meta:
        ordering = ('created',)


    def __str__(self):
        return self.content[:20]    # 显示前20个字符


